#pragma once

#include <gofcl_usart_r.h>

typedef struct {
	u32_s PERR : 1;
	u32_s FERR : 1;
	u32_s NERR : 1;
	u32_s ORERR : 1;
	u32_s IDLEF : 1;
	u32_s RBNE : 1;
	u32_s TC : 1;
	u32_s TBE : 1;
	u32_s LBDF : 1;
	u32_s CTSF : 1;
	u32_s : 22;
} usart_stat_s;

_Static_assert(sizeof(usart_stat_s) == 4, "Struct usart_stat_s defined error!");

static inline usart_stat_s usart_rreg_stat_s(usart_qe usart_q) {
	union {
		usart_stat_s s;
		u32_s u;
	} su = {
		.u = usart_rreg(usart_q, USART_STAT_R),
	};
	return su.s;
}
